package train.DAY618;

public class Test1 {
    //删除排序数组的重复项
    public static void main(String[] args) {
        int[] nums={1,1,1};
        int[] nums1={0,0,1,1,1,2,2,3,3,4};
        int remove = Remove(nums1);
        System.out.println(remove);

    }

//是否相同
    public static int Remove(int[] nums){
        int num = 0;
        int same=0;
        int a=0;
        for (int i = 1; i < nums.length; i++) {
            if(i==nums.length-same)
                break;
            int j=i-1;

            while(j>=0){

                if(nums[i]==nums[j]) {
                    int[] change = Change(nums, j);
                    same++;
                    if(nums.length-same==i) {a=1 ;break;}
                }else
                { j--;}

            }
            if(a==1) break;

        }
        for(int i=0;i<nums.length-1;i++){
            if(nums[i]==nums[i+1])
            { num=i+1;break;}
            else num=i+2;
        }
        if(nums.length==1)
             num=1;
        return  num;
    }

    //移动数据部分
    public static int[] Change(int[] nums,int j){
        for (int i = j; i < nums.length-1; i++) {
            nums[i]=nums[i+1];
        }
        return nums;
    }
}
